package com.dz.risk.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dz.risk.common.ResponseVO;
import com.dz.risk.common.exception.RRException;
import com.dz.risk.pojo.QueryParams;
import com.dz.risk.pojo.domain.BondRiskInformationSheetEntity;
import com.dz.risk.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 债券风险信息表
 *
 * @author yinpl
 * @email 
 * @date 2021-07-08 10:36:32
 */
@RestController
@RequestMapping("dz-ftsp/stest/bondriskinformationsheet")
@Api(tags = "债券风险信息表api", value = "债券风险信息表接口")
public class BondRiskInformationSheetController {
    @Autowired
    private BondRiskInformationSheetService bondRiskInformationSheetService;
    @Autowired
    private DebtBasicInformationCalculationService debtBasicInformationCalculationService;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * 查询债券风险信息表
     *
     */
    @ApiOperation("查询债券风险信息表")
    @PostMapping(value = "/query")
    public ResponseVO query(@RequestBody QueryParams queryParams) {
        IPage<BondRiskInformationSheetEntity> iPage =null;
        try {
            iPage = bondRiskInformationSheetService.query(queryParams);
        } catch (RRException e) {
            e.printStackTrace();
            logger.error("查询日志信息失败！" + e);
            return new ResponseVO(e.getCode(), e.getMessage());
        }
        return ResponseVO.ok(iPage);

    }

    @ApiOperation("导出债券风险信息表")
    @GetMapping("/doExport")
    public void doExport(HttpServletResponse response, QueryParams queryParams) throws IOException {
        final String fileName = "债券风险信息表_%s.xlsx";
        bondRiskInformationSheetService.doExportByVersion(response, queryParams);
    }


}
